package org.alis.rpc.common.paap.config;

import org.alis.rpc.common.paap.AppConfigContext;
import org.alis.rpc.common.paap.Configurator;
import org.alis.rpc.common.paap.cache.ConfigCacheService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.PriorityOrdered;

/**
 * @author lc
 * @version v1.0.0
 * @date 2020/8/28 14:08
 * @className BeanConfigurator.class
 */
@ImportResource(value = "classpath:spring/application-context.xml")
@Configuration
public class BeanConfigurator implements PriorityOrdered {

    @Bean(name = "appConfigContext")
    public AppConfigContext appConfigContext(){
        return new AppConfigContext();
    }

    @Bean(name = "appConfigConfigurator")
    public Configurator configurator(){
        Configurator configurator = new Configurator();
        configurator.setConfigCacheService(appConfigConfigCacheService());
        return configurator;
    }

    @Bean
    public ConfigCacheService appConfigConfigCacheService(){
        ConfigCacheService cacheService = new ConfigCacheService();
        cacheService.setAppIds(StringUtils.EMPTY);
        cacheService.setSysId(StringUtils.EMPTY);
        cacheService.setAppconfigServerUrl(StringUtils.EMPTY);
        return cacheService;
    }



    @Override
    public int getOrder() {
        return 2;
    }
}
